﻿<phone:PhoneApplicationPage x:Class="EmperialApps.WeatherSpark.SettingsPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:local="clr-namespace:EmperialApps.WeatherSpark"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            Orientation="Portrait"
                            SupportedOrientations="Portrait"
                            mc:Ignorable="d"
                            d:DesignHeight="768"
                            d:DesignWidth="480"
                            shell:SystemTray.IsVisible="True">

    <Grid x:Name="LayoutRoot"
          Background="Transparent">
        <phone:Pivot Title="WᴇᴀᴛʜᴇʀSᴘᴀʀᴋ">
            <phone:PivotItem Header="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Source_header}">
                <StackPanel Margin="{StaticResource PhoneHorizontalMargin}">
                    <TextBlock Style="{StaticResource PhoneTextExtraLargeStyle}"
                               x:Name="ForecastDescription"
                               Margin="0"
                               Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.Graph_LoadingFallback}"
                               TextWrapping="Wrap" />
                    <TextBlock Style="{StaticResource PhoneTextTitle3Style}"
                               x:Name="ForecastLocation"
                               Margin="0"
                               Text=" " />
                    <Button Margin="-12,12,0,0"
                            Padding="24,3,24,5"
                            Click="OnLocationButtonClicked"
                            Content="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Source_ChangeLocation}"
                            HorizontalAlignment="Left" />

                    <TextBlock Style="{StaticResource PhoneTextTitle3Style}"
                               x:Name="ForecastSource"
                               Margin="{StaticResource SeparatorMargin}"
                               TextWrapping="Wrap" />

                    <StackPanel x:Name="LinkContainer">
                        <StackPanel.Resources>
                            <Style TargetType="HyperlinkButton">
                                <Setter Property="HorizontalAlignment"
                                        Value="Left" />
                                <Setter Property="Margin"
                                        Value="{StaticResource SeparatorMargin}" />
                                <Setter Property="Foreground"
                                        Value="{StaticResource PhoneAccentBrush}" />
                                <Setter Property="TargetName"
                                        Value="_blank" />
                            </Style>
                        </StackPanel.Resources>
                    </StackPanel>
                </StackPanel>
            </phone:PivotItem>

            <phone:PivotItem Header="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_header}">
                <StackPanel Margin="{StaticResource PhoneHorizontalMargin}">
                    <StackPanel.Resources>
                        <Style TargetType="toolkit:ListPickerItem">
                            <Setter Property="Padding"
                                    Value="0" />
                        </Style>
                    </StackPanel.Resources>

                    <TextBlock Style="{StaticResource SettingDescription}"
                               Margin="0"
                               Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_Nickname_header}" />
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBox x:Name="TileTitle"
                                 InputScope="AddressCity"
                                 TextChanged="OnTileTitleChanged" />
                    </Grid>

                    <TextBlock Style="{StaticResource SettingDescription}"
                               Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_LiveTile_header}" />
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="TileLabelRow"
                                           Height="Auto" />
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="0"
                                   Style="{StaticResource PhoneTextSubtleStyle}"
                                   FontStyle="Italic"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_LiveTile_Front}" />
                        <toolkit:ListPicker x:Name="TileFront"
                                            Grid.Column="0"
                                            Grid.Row="1"
                                            Background="{StaticResource TransparentBrush}"
                                            BorderThickness="0"
                                            ExpansionMode="FullScreenOnly"
                                            Foreground="{StaticResource PhoneForegroundBrush}"
                                            FullModeHeader="Live tile"
                                            FullModeItemTemplate="{StaticResource TileHorizontalTemplate}"
                                            ItemTemplate="{StaticResource TileItemTemplate}"
                                            Margin="{StaticResource PhoneHorizontalMargin}"
                                            SelectionChanged="OnTileSelectionChanged">
                            <local:TileOption DisplayMode="None" />
                            <local:TileOption DisplayMode="Day" />
                            <local:TileOption DisplayMode="Hour" />
                        </toolkit:ListPicker>

                        <TextBlock Grid.Column="1"
                                   Grid.Row="0"
                                   Style="{StaticResource PhoneTextSubtleStyle}"
                                   FontStyle="Italic"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_LiveTile_Back}" />
                        <toolkit:ListPicker x:Name="TileBack"
                                            Grid.Column="1"
                                            Grid.Row="1"
                                            Background="{StaticResource TransparentBrush}"
                                            BorderThickness="0"
                                            ExpansionMode="FullScreenOnly"
                                            Foreground="{StaticResource PhoneForegroundBrush}"
                                            FullModeHeader="Live tile back"
                                            FullModeItemTemplate="{StaticResource TileBackHorizontalTemplate}"
                                            ItemTemplate="{StaticResource TileBackItemTemplate}"
                                            Margin="{StaticResource PhoneHorizontalMargin}"
                                            SelectionChanged="OnTileBackSelectionChanged" />

                        <Button x:Name="AdvancedTileSettingsButton"
                                Grid.Row="2"
                                Margin="0,0,0,-9"
                                Content="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_LiveTile_Advanced}"
                                Click="OnAdvancedTileSettingsButtonClicked" />
                    </Grid>

                    <TextBlock Style="{StaticResource SettingDescription}"
                               Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_Units_header}" />
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <RadioButton x:Name="MetricUnitsButton"
                                     Grid.Column="0"
                                     Click="OnUnitButtonClicked"
                                     Content="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_Units_Metric}" />
                        <RadioButton x:Name="ImperialUnitsButton"
                                     Grid.Column="1"
                                     Click="OnUnitButtonClicked"
                                     Content="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Tile_Units_Imperial}" />
                    </Grid>
                </StackPanel>
            </phone:PivotItem>

            <phone:PivotItem Header="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Summary_header}">
                <Grid Margin="{StaticResource PhoneHorizontalMargin}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Style="{StaticResource SettingDescription}"
                               Grid.Row="1"
                               Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_DisplayLevel_header}" />
                    <local:ForecastDisplaySelector x:Name="SummaryPageSelector"
                                                   Grid.Row="2"
                                                   MinimumDisplayLevel="Set,TemperatureDetails" />

                    <TextBlock Style="{StaticResource SettingDescription}"
                               Grid.Row="3"
                               Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_ShowExtremesUsingNight_header}" />
                    <toolkit:ToggleSwitch x:Name="ShowNightExtremesButton"
                                          Grid.Row="4"
                                          Click="OnShowNightExtremesButtonClicked" />

                    <local:WeatherSummary x:Name="SummaryPageGraph"
                                          Grid.Row="0"
                                          DisplayLevel="{Binding ElementName=SummaryPageSelector, Path=DisplayLevel}"
                                          IsHitTestVisible="False"
                                          ShowExtremesUsingNight="{Binding ElementName=ShowNightExtremesButton, Path=IsChecked}" />
                </Grid>
            </phone:PivotItem>

            <phone:PivotItem Header="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_Detail_header}">
                <Grid Margin="{StaticResource PhoneHorizontalMargin}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Style="{StaticResource SettingDescription}"
                               Grid.Row="1"
                               Text="{Binding Mode=OneTime, Source={StaticResource Localized}, Path=Strings.SettingsPage_DisplayLevel_header}" />
                    <local:ForecastDisplaySelector x:Name="DetailPageSelector"
                                                   Grid.Row="2"
                                                   MinimumDisplayLevel="Set,TemperatureSummary" />

                    <local:WeatherGraph x:Name="DetailPageGraph"
                                        Grid.Row="0"
                                        DisplayLevel="{Binding ElementName=DetailPageSelector, Path=DisplayLevel}"
                                        IsHitTestVisible="False" />
                </Grid>
            </phone:PivotItem>
        </phone:Pivot>

        <Rectangle x:Name="TileProgress"
                   Style="{StaticResource TileProgressIndicator}">
            <Rectangle.Clip>
                <PathGeometry />
            </Rectangle.Clip>
        </Rectangle>
    </Grid>
</phone:PhoneApplicationPage>
